//
//  TestingPaperVC.m
//  JW_BasePorject
//
//  Created by JW on 2018/6/25.
//  Copyright © 2018年 JW. All rights reserved.
//

#import "TestingPaperVC.h"
#import "PaperProgressView.h"
#import "PaperQuestionView.h"

#import <DTCoreText/DTCoreText.h>

#import "SingleOption.h"

#import "ThemeFontView.h"


#import <TTGTextTagCollectionView.h>

@interface TestingPaperVC ()
@property (nonatomic,strong)UILabel *YLabel;

@property (nonatomic,strong)UIWebView *webView;


@end

@implementation TestingPaperVC
{
    
    PaperProgressView *view;
    NSInteger index;
    BOOL up;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    index = 0;
    up= 0;
    self.title = @"使用帮助";
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];

//    [self testYYlabel];
    
//    [self testPaperProgress];
    
//    [self testQuestionView];
    
//    [self testDTCoreTextLabel];
    
//    [self testSingleOption];
    
//    [self testThemeFontView];
    
//    [self testTTGTextTagCollectionView];
}


- (void)testTTGTextTagCollectionView{
    
    TTGTextTagConfig *config = [[TTGTextTagConfig alloc] init];
    config.tagBackgroundColor = [UIColor whiteColor];
    config.tagBorderColor = [UIColor lightGrayColor];
    config.tagTextColor = [UIColor lightGrayColor];
    
    TTGTextTagCollectionView *tagCollectionView = [[TTGTextTagCollectionView alloc] initWithFrame:CGRectMake(20, 20, SCREEN_WIDTH - 40, 200)];// WithFrame:CGRectMake(20, 20, SCREEN_WIDTH - 40, 200)
    tagCollectionView.backgroundColor = [UIColor redColor];
    tagCollectionView.enableTagSelection = NO;
    tagCollectionView.defaultConfig = config;
    [self.view addSubview:tagCollectionView];
    NSLog(@"1-%@",NSStringFromCGSize(tagCollectionView.contentSize));

    [tagCollectionView addTags:@[@"五、特装修防火要求",@"str史蒂夫ing1"]];
    [tagCollectionView addTags:@[@"五、特装修防火要求",@"str史蒂夫ing1"]];

    [tagCollectionView addTags:@[@"五、特装修防火要求",@"str史蒂夫ing1"]];

    [tagCollectionView addTags:@[@"五、特装修防火要求",@"str史蒂夫ing1"]];

    NSLog(@"2-%@",NSStringFromCGSize(tagCollectionView.contentSize));

    [tagCollectionView addTag:@"五、相对运动"];
    NSLog(@"3-%@",NSStringFromCGSize(tagCollectionView.contentSize));
    NSLog(@"4-%f",SCREEN_WIDTH-40);

    tagCollectionView.sd_layout
    .leftSpaceToView(self.view, 20)
    .rightSpaceToView(self.view, 20)
    .topSpaceToView(self.view, 20)
    .heightIs(tagCollectionView.contentSize.height+4);
//    [tagCollectionView setupAutoHeightWithBottomView:subview2 bottomMargin:10];

}


- (void)testThemeFontView{
    ThemeFontView *view = [[ThemeFontView alloc] initWithFrame:CGRectMake(0, NavigationBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - NavigationBarHeight)];
    [view showInView:self.view];
    
}

- (void)testSingleOption{
    SingleOption *view = [[SingleOption alloc] initWithFrame:CGRectMake(10, 80, SCREEN_WIDTH- 20,0)];
//    view.backgroundColor = [UIColor redColor];
    [self.view addSubview:view];
        
}

- (void)testDTCoreTextLabel{
    DTAttributedTextView *attributedLabel = [[DTAttributedTextView alloc] initWithFrame:CGRectZero];
//    NSString *html = @"<html><body>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commasfasfadsfasfdasfdsafadsfadsfadsfadsfasfsdfadsfasdfsaodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillumasfasfadsfasfdasfdsafadsfadsfadsfadsfasfsdfadsfasdfsaodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolorasfasfadsfasfdasfdsafadsfadsfadsfadsfasfsdfadsfasdfsaodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolor dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</body></html>";
    
    NSString *html = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"FakeData" ofType:@""] encoding:NSUTF8StringEncoding error:nil];
    
    NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
    attributedLabel.backgroundColor =[UIColor redColor];
    NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL];
    attributedLabel.attributedString = attributedString;
    
    DTCoreTextLayouter *layouter = [[DTCoreTextLayouter alloc] initWithAttributedString:attributedString];
    
    CGRect maxRect = CGRectMake(10, 80, SCREEN_WIDTH- 20, CGFLOAT_HEIGHT_UNKNOWN);
    NSRange entireString = NSMakeRange(0, [attributedString length]);
    DTCoreTextLayoutFrame *layoutFrame = [layouter layoutFrameWithRect:maxRect range:entireString];
    
    CGSize sizeNeeded = [layoutFrame frame].size;
    
    
    attributedLabel.frame = CGRectMake(10, 80 ,SCREEN_WIDTH- 20, 200);
    [self.view addSubview:attributedLabel];
//    attributedLabel.sd_layout
//    .topSpaceToView(self.view, 80)
//    .leftSpaceToView(self.view, 10)
//    .rightSpaceToView(self.view, 10)
//    .autoHeightRatio(1);
    
}


- (void)testQuestionView{
    PaperQuestionView * view = [[PaperQuestionView alloc] initWithFrame:CGRectMake(10, 64 ,SCREEN_WIDTH- 20, SCREEN_HEIGHT - 64) style:UITableViewStyleGrouped];
    view.backgroundColor =[UIColor redColor];
    [self.view addSubview:view];
}




- (void)testPaperProgress{
    view = [[PaperProgressView alloc] initWithFrame:CGRectMake(10, 80, SCREEN_WIDTH-20, 50)];
    view.currentIndex = 0;
    view.totalNum = 5;
    view.sliderTitle = @"测试一下";
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(100, 250, 100, 100);
    btn.backgroundColor = [UIColor redColor];
    [btn addTarget:self action:@selector(click_paper:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
}

- (void)click_paper:(UIButton *)sender{
    if (index == 5) {
        up = !up;
    }
    
    if (up == 0) {
        index++;
    }else{
        index--;
    }
    if (index == 0) {
        up = !up;
    }
    
    view.currentIndex = index;

}




- (void)testYYlabel{
    _YLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, SCREEN_WIDTH-10, SCREEN_HEIGHT - 64 )];
    _YLabel.lineBreakMode = NSLineBreakByCharWrapping;
    _YLabel.numberOfLines = 0;

    
    
//    NSString *htmlStr = @"测试<img src=http://zby2018.oss-cn-beijing.aliyuncs.com/ueditor/20180625/5b3090ec2b6ba.jpg title=u=2361699408,3021938713&fm=27&gp=0.jpg alt=u=2361699408,3021938713&fm=27&gp=0.jpg/>士大夫士大夫士大夫";
    NSString *htmlStr = @"<span style=\"color:#333;font-size:15px;\"><strong>砍价师服务介绍</strong></span><br/><span align=\"right\" style=\"color:#333;font-size:15px;\">我们不是中介。</span><br/> <span style=\"color:#333;font-size:15px;\">我们是一群愿意站在买房人一边的，地产业内人士。</span><br/><br/><span style=\"color:#333;font-size:15px;\"><strong>砍不下来，不要钱！</strong></span><br/><span style=\"color:#333;font-size:15px;\">类似你请个律师，完全站在你的立场，帮你谈判。我们发心，用立场和专业，改变中国买房人的被动、挨宰局面！</span><br/><br/><span style=\"color:#333;font-size:15px;\"><strong>服务流程：</strong></span><br/><span style=\"color:#333;font-size:15px;\">1.砍前培训。砍价师教你和中介、业主交流，哪些话能说，哪些话不能说；</span><br/><span style=\"color:#333;font-size:15px;\">2.选砍价师。和砍价师约见，确认服务，并做各方信息梳理，确定谈判策略。</span><br/><span style=\"color:#333;font-size:15px;\">3.现场谈判。砍价师陪你去现场，协助把控谈判进程；在你砍不动时，再继续全力争取最好价格。</span><br/><br/><span style=\"color:#333;font-size:15px;\"><strong>收费标准：</strong></span><br/><span style=\"color:#333;font-size:15px;\">记住！砍价是由你自己先砍，砍不动时再由砍价师继续砍；由砍价师多砍下的部分，才按照下列标准收费：</span><br/><span style=\"color:#333;font-size:15px;\"><img src=\"http://cn-qinqimaifang-uat.oss-cn-hangzhou.aliyuncs.com/img/specialist/upload/spcetiicwlz1v_54e2e00fa8a6faf66168571654dbfee2.jpg\" _src=\"http://cn-qinqimaifang-uat.oss-cn-hangzhou.aliyuncs.com/img/specialist/upload/spcetiicwlz1v_54e2e00fa8a6faf66168571654dbfee2.jpg\"></span><span style=\"color:#333;font-size:15px;\"><strong>砍不下来，不收费！</strong></span><br/><br/><span style=\"color:#333;font-size:15px;\"><strong>举个例子：</strong></span><br/><span style=\"color:#333;font-size:15px;\">李先生看好一套房子，经过自己努力将价格砍到300万，砍价师在李先生的基础上将价格谈到270万，成功砍下30万，其中0~5万元阶梯价格部分为5万元，5~10万元阶梯价格部分为5万元，10万元以上阶梯价格部分为20万元，则</span><br/><span style=\"color:#333;font-size:15px;\"><strong>应收服务费：5x30％+5x40%+20x50%=13.5万</strong></span><br/><br/><span style=\"color:#333;font-size:15px;\">百度:<a href=\"http://www.w3school.com.cn\">my testlink</a></span><br/><br/><span style=\"color:#333;font-size:15px;\">电话：<a href=\"tel:4008001234\">my phoneNum</a></span><br/><br/><span style=\"color:#333;font-size:15px;\">我邮箱:<a href=\"mailto:dreamcoffeezs@163.com\">my mail</a></span>";

    NSAttributedString *att = [[NSAttributedString alloc] initWithData:[htmlStr dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];
    
    _YLabel.attributedText = att;
    
    [self.view addSubview:_YLabel];

    
}

- (void)testWebview{
    
    
//    NSString *htmlString = @"<article><header><h3>APP使用帮助说明</h3></header><section><h4>如果收不到验证码怎么办？</h4><p>注册、修改密码、忘记密码、预约等收不到验证码时。首先检查输入手机号码是否正确；其次检查手机信号、网络是否良好。</section><section><h4>APP没有数据怎么办？</h4></p><p>苹果手机针对iOS 10.0以上系统，找到【设置】--【蜂窝移动网络】--【使用无线局域网与蜂窝移动应用】找到百“通世纪APP”选择【无线局域网与蜂窝移动应用】重新刷新APP即可，如果失败请重新启动手机尝试。</p></section><section><h4>忘记密码如何更改？</h4><p>【首页】右上角【登录】找到“忘记密码”选项，输入注册时预留的手机号，“获取验证码”，根据提示输入两次一致的新密码，点击“重置密码”按钮会提示修改成功，可使用新密码登录。</p></section><section><h4>报班学员如何验证身份？</h4><p>【我】--【账户管理】--【电话】输入框中输入报班时预留的手机号即可成为“百通学员”，输入正确在【我】用户名下方会显示“百通学员（已验证）”，否则显示“普通学员”。</p></section><section><h4>报班学员如何进入学习直播课堂？</h4><p>登录的学员（没登录的学员会提示请先登录）点击【首页】--【我的课堂】或者【我】--【我的课堂】选择对应班次，输入 “真实姓名+直播密码”可直接进入当前直播。</p></section><section><h4>报班学员错过直播怎么办？</h4><p>【我的课堂】--【历史课程】点击【播放】即可观看错过的直播。</p></section><section><h4>免费直播（公开课）如何观看流程？</h4><p>在【首页】顶部选择专业会显示对应直播信息，如果正在直播点击“直播中”按钮可直接进入当前直播。</p></section><footer><h5>Ps:如果以上方法不能解决您的问题或者有其它疑问，微信搜索：“baitongshijijishu”添加技术哥哥为好友，技术哥哥会亲自为您服务。</h5></footer></article>";
    
//    for (int i = 1; i< 6; i++) {
//        UIWebView *webView =[[UIWebView alloc]initWithFrame:CGRectMake(0, 0+80*i, SCREEN_WIDTH, 50)];
//        NSLog(@"%d",i);
//        NSString *htmlString = @"测试<img src=http://zby2018.oss-cn-beijing.aliyuncs.com/ueditor/20180625/5b3090ec2b6ba.jpg title=u=2361699408,3021938713&fm=27&gp=0.jpg alt=u=2361699408,3021938713&fm=27&gp=0.jpg/>士大夫士大夫士大夫";
//        NSString *str = [NSString stringWithFormat:@"%d-%@",i,htmlString];
//        [webView loadHTMLString:str baseURL:nil];
//        [self.view addSubview:webView];
//
//    }
    
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
